package com.acme.bankapp.domain.bank;

import com.acme.bankapp.exceptions.NotEnoughFundsException;

/**
 * This is saving variant of particular implementation of abstract account
 * 
 * @author Anton Kotov
 * 
 */
public class SavingAccount extends AbstractAccount {

	public SavingAccount(final int id, final double balance) {
		super(id, balance);
		
		if (balance < 0.) {
			throw new IllegalArgumentException();
		}
	}

	public void withdraw(final double amount) throws NotEnoughFundsException {
		if (amount <= 0.) {
			throw new IllegalArgumentException();
		}
		super.withdraw(amount);
		assert (balance >= 0.) : "balance is negative";
	}

	@Override
	public double maximumAmountToWithdraw() {
		return getBalance();
	}
	
	@Override
	public String toString() {
		return super.toString() + " -> SavingingAccount";
	}
}
